package yi.wuhenbot.Service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import yi.wuhenbot.dao.GroupMessageMapper;
import yi.wuhenbot.entity.GroupMessage;

@Service("groupMessageService")
public class GroupMessageService {
    @Autowired
    private GroupMessageMapper groupMessageMapper;
    /**
     * 插入群消息
     */
    public void insertGroupMessage(String groupid){
        groupMessageMapper.insertGroupMessage(groupid);
    }
    /**
     * 根据群id查询message
     * @param groupid 群id
     * @return 消息内容-单条
     */
    public String selectGroupMessageByGroupid(String groupid){
        return groupMessageMapper.selectGroupMessageByGroupid(groupid).getMessage();
    }
    /**
     * 更新群消息
     * @param groupid 群id
     * @param message 消息内容
     */
    public void updateGroupMessageByGroupid(String groupid,String message){
        groupMessageMapper.updateGroupMessageByGroupid(groupid,message);
    }
    /**
     * 检查本群是否有messages
     * @param groupid 群id
     * @return 是否存在
     */
    public boolean isGroupMessageExist(String groupid){
        return groupMessageMapper.isGroupMessageExist(groupid);
    }
    /**
     * 检查本群是否存在
     * @param groupid 群id
     * @return 是否存在
     */
    public boolean isGroupExist(String groupid){
        return groupMessageMapper.isGroupExist(groupid);
    }


}
